package org.example.controller;

import lombok.RequiredArgsConstructor;
import org.example.dto.DataRequestDto;
import org.example.entity.Data;
import org.example.service.DataService;
import org.example.service.UserService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
public class DataController {

    private final DataService userService;

    @PostMapping("/data")
    public ResponseEntity<Data> createUser(@RequestBody DataRequestDto requestDTO) {
        Data user = new Data();
        user.setData(requestDTO.getData());
        Data savedUser = userService.saveData(user);
        return ResponseEntity.ok(savedUser);
    }


}
